﻿using System;
using System.Windows;
using Csla.Xaml;
using Accounting.Library;

namespace csla4Skeleton.UI.SL.NghiepVu.BanSanPham.BSP_BanDichVu
{
    public partial class BSP_BanDichVu_ListViewModel : ViewModel<BSP_BanDichVuList>
    {

        public BSP_BanDichVu_ListViewModel(string mode)
        {
            BeginRefresh("GetBSP_BanDichVuList", mode);
        }

        public void GetBSP_BanDichVu_ListViewModel(string mode)
        {
            BeginRefresh("GetBSP_BanDichVuList", mode);
        }

        public static readonly DependencyProperty SelectedItemProperty =
          DependencyProperty.Register("SelectedItem", typeof(BSP_BanDichVuInfo), typeof(BSP_BanDichVu_ListViewModel), null);
        public BSP_BanDichVuInfo SelectedItem
        {
            get { return (BSP_BanDichVuInfo)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        public void DeleteBSP_BanDichVu(object sender, ExecuteEventArgs e)
        {
            if (e.MethodParameter != null)
            {
                //cast OrderID parameter
                int Khoa = Int16.Parse(e.MethodParameter.ToString());
                this.IsBusy = true;
                Accounting.Library.BSP_BanDichVu.DeleteBSP_BanDichVu(Khoa, (o, ex) =>
                {
                    BeginRefresh("GetBSP_BanDichVuList",BusinessConfiguration.Configuration.GridViewFetchMode);
                });
                this.IsBusy = false;
            }
        }

        internal void DeleteBSP_BanDichVu(int Khoa)
        {
            this.IsBusy = true;
            Accounting.Library.BSP_BanDichVu.DeleteBSP_BanDichVu(Khoa, (o, ex) =>
            {
                BeginRefresh("GetBSP_BanDichVuList", BusinessConfiguration.Configuration.GridViewFetchMode);
            });
            this.IsBusy = false;
        }
    }
}
